
package com.pms.actions;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Hashtable;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.pms.framework.Action;
import com.pms.framework.JSPUtility;

public class CommonAction implements Action {

	public void execute(HttpServletRequest request, HttpServletResponse response) {
		Hashtable error = (Hashtable) request.getAttribute("error");

		if(error.size() > 0){
			request.setAttribute("nextPageToken", "needLogin");
			request.setAttribute("plainPage", "TRUE");
			return;
		}

		if(request.getSession().getAttribute("user")==null){
			request.setAttribute("nextPageToken", "needLogin");
			request.setAttribute("plainPage", "TRUE");
			return;
		}
		if(request.getParameter("plainpage")!=null && request.getParameter("plainpage").toString().equalsIgnoreCase("true")){
			request.setAttribute("plainPage", "TRUE");
		}

		if(request.getParameter("reportIndx")!=null && !"".equals(request.getParameter("reportIndx").toString())){
			request.setAttribute("reportIndx", JSPUtility.GetInt(request, "reportIndx", 0));
		}
		SimpleDateFormat objDateFormat = new SimpleDateFormat("yyyy-MM-dd");
		Date obj = new Date();
		String psCurrentDate = objDateFormat.format(obj);
		request.setAttribute("CurrentDate",psCurrentDate);
		
		String prevSelMenu = JSPUtility.GetString(request, "PrevSelMenu","");
		request.setAttribute("PrevSelMenu", prevSelMenu);
		System.out.println("@@@@@@@ prevSelMenu ===> "+prevSelMenu);
		request.setAttribute("nextPageToken", "success");
	}
}

